<template>
  <div class="container">
    <el-dialog
      width="800px"
      title="预览文章"
      :visible="isShowPreview"
      @close="handleCancel"
    >
      <template>
        <h2>{{ currentArt.title }}</h2>
        <div class="info">
          <span>{{ currentArt.createTime | parseTimeByString }}</span>
          <span>{{ currentArt.username }}</span>
          <span class="el-icon-view"></span>
          <span>{{ currentArt.visits }}</span>
        </div>
        <div class="content" v-html="currentArt.articleBody">
          {{ currentArt.articleBody }}
        </div>
      </template>
    </el-dialog>
  </div>
</template>

<script>
import { parseTimeByString } from '@/filters'
export default {
  props: {
    isShowPreview: Boolean,
    currentArt: {
      type: Object,
      default: () => {
        return {}
      }
    }
  },
  filters: {
    parseTimeByString (value) {
      return parseTimeByString(value)
    }
  },
  methods: {
    handleCancel () {
      this.$emit('update:isShowPreview', false)
    }
  }
}
</script>

<style scoped lang="less">
h2 {
  margin: 0;
}
.info {
  margin: 8px 0;
  span {
    margin-left: 10px;
    color: #999;
  }
}
.content {
  padding: 10px;
  background: #f5f5f5;
  border-top: 1px dashed #999;
}
</style>
